﻿using System.Text.RegularExpressions;

namespace FreeBroker
{
    public class CategoryRegExes
    {
        public static Regex GetAdditionalInfo(InformerType type)
        {
            if (type.Category == InformerType.CAT_BROKER)
            {
                return new Regex("name=\"informerForm\".+?<h1>\\s+?(?<title>.+?)(\r|<).+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?>Typ:.+?b>(?<type>.+?)<.+?B&ouml;rse:(?<market>.+?)<.+?first\">Aktuell<.+?<td(><img.+?0\">|>)(?<value>.+?)</.+?Symbol.+?<td>(?<symbol>.+?)<.+?ISIN.+?\"alignRight\">(?<isin>.+?)<.+?WKN.+?<td>(?<wkn>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_CERTIFICATE)
            {
                return new Regex("name=\"informerForm\".+?<h1>(?<title>.+?)(\r|<).+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?B&ouml;rse<.+?\">(?<market>.+?)<.+?>Aktuell<.+?>&nbsp;(?<value>.+?)<.+?Typ<.+?title=\"(?<type>.+?)\".+?Symbol<.+?\">(?<symbol>.+?)<.+?ISIN<.+?\">(?<isin>.+?)<.+?WKN<.+?\">(?<wkn>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_CALL)
            {
                return new Regex("name=\"informerForm\".+?<h1>(\\s*<span.+?=\"(?<title>.+?)\">|(?<title>.+?))<a.+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?>Typ:<.+?b>(?<type>.+?)<.+?B&ouml;rse<.+?\">(?<market>.+?)<.+?Aktuell<.+?\">(?<value>.+?)<.+?W&auml;hrung<.+?\">(?<currency>.+?)<.+?Symbol<.+?\">(?<symbol>.+?)<.+?ISIN<.+?\">(?<isin>.+?)<.+?WKN<.+?\">(?<wkn>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_INDEX)
            {
                return new Regex("name=\"informerForm\".+?<h1>(?<title>.+?)<.+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?Typ:&nbsp;<b>(?<type>.+?)<.+?>B&ouml;rse:\\s+(<span.+?=\"(?<market>.+?)\"|(?<market>.+?)</p>).+?first\">Aktuell<.+?<td>(<img.+?0\">|\\s*)(?<value>.+?)<.+?first\">Symbol<.+?<td>(?<symbol>.+?)<.+?first\">WKN<.+?<td>(?<wkn>.+?)<.+?first\">ISIN<.+?<td>(?<isin>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_FUND)
            {
                return new Regex("name=\"informerForm\".+?<h1>(\\s*<span.+?=\"(?<title>.+?)\">|(?<title>.+?))(<a|<img.+?|\\r\\s*).+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?Typ:&nbsp;<b>(?<type>.+?)<.+?B&ouml;rse.+?=\"(?<market>.+?)\".+?\">R&uuml;cknahmepreis<.+?<td>(?<value>.+?)<.+?>W&auml;hrung<.+?\"alignRight\">(?<currency>.+?)<.+?>ISIN<.+?\"alignRight\">(?<isin>.+?)<.+?\">WKN<.+?\"alignRight\">(?<wkn>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_BOND)
            {
                return new Regex("name=\"informerForm\".+?<h1>(?<title>.+?)<.+?id=\"keyelement_partialupdate\".+?\"fcRed\">(?<date>.+?)<.+?>Typ:&nbsp;<b>(<span.+?=\"(?<type>.+?)\"|(?<type>.+?)<).+?\">B&ouml;rse<.+?<td>(?<market>.+?)<.+?\">Aktuell<.+?<td>(<img.+?0\">(?<value>.+?)|(?<value>.+?))<.+?\">W&auml;hrung<.+?\"alignRight\">(?<currency>.+?)<.+?\">ISIN<.+?\"alignRight\">(?<isin>.+?)<.+?\">WKN<.+?\"alignRight\">(?<wkn>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else if (type.Category == InformerType.CAT_CURRENCY)
            {
                return new Regex("name=\"informerForm\".+?<h1>\\s+?(?<title>.+?)(\r|<).+?id=\"keyelement_kurs_update\".+?\"fcRed\">(?<date>.+?)<.+?>Typ:.+?b>(?<type>.+?)<.+?>B&ouml;rse<.+?\">(?<market>.+?)<.+?\">Aktuell<.+?<p.+?\"(><img.+?0\">|>)(?<value>.+?)</.+?\">Symbol.+?<p.+?\">(?<symbol>.+?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            }
            else
            {
                return null;
            }
        }
    }
}
